window.onload = function (){
    getUser();
    getChannel();
};

async function getUser() {
    let user =await ajaxGet("/user/getLoginUser");
    $("userImg").src = "/html/img/"+user.facePath
    $("nameSpan").innerHTML = user.username;
    $("emailSpan").innerHTML = user.email;
}

async function getChannel() {
    let channel = await ajaxGet("/channel/findAll");
    var str = "";
    for (let i = 0; i < channel.length; i++) {
        let c1 = channel[i];
        str += `<tr>
                    <td>
                        <a style="text-decoration: none" href="/html/main.html?id=${c1.channelId}">${c1.channelName}</a>
                    </td>
                    <td>${c1.channelInfo}</td>
                    <td>${c1.num}</td>
                </tr>`;
    }
    $("channelData").innerHTML = str;
}